<%@page import="org.quickbundle.project.RmGlobalReference"%>
<%@page import="com.dfhc.ISystemConstant"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/GX_css/base.css" />
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/GX_css/works.css" />
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/GX_css/info-mgt.css" />
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/GX_css/WdatePicker.css" /> 
    <link  type="text/css" rel="stylesheet" href="<%=request.getContextPath()%>/css/GX_css/jquery-ui.css">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/GX_css/jquery.treeview.css" />
    
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/GX_js/jquery-1.10.1.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/GX_js/jquery-ui.min.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/GX_js/common.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/GX_js/info-mgt.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/GX_js/WdatePicker.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/GX_js/jquery.pagination.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/process/path.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/rm-tools.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/ajaxfileupload.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/app-pub.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/GX_js/jquery.treeview.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/myalert.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/myalert.js"></script>
   
    <title>办公自动化系统</title>
    <style type="text/css">
    	.zu_add_dialog{ width:510px; height:550px; background:#FFFFFF; position: fixed; top:20%; border-radius:4px; padding:3px; border:1px solid #C5C5C5}
        .zu_add_dialog ul{display: block; float: left; width:100%; height:auto; height:40px;}
		
		#process_model_dialog ul{text-align:center;width:100%;}
		#process_model_dialog ul li{float:left;}
		#process_model_dialog ul li input{width:30px;}
		#process_model_dialog ul li:nth-child(1){width:15%;}
		#process_model_dialog ul li:nth-child(2){width:15%;}
		#process_model_dialog ul li:nth-child(3){width:70%;}
		
		#user_dialog ul{text-align:center;width:100%;}
		#user_dialog ul li{float:left;}
		#user_dialog ul li input{width:30px;}
		#user_dialog ul li:nth-child(1){width:15%;}
		#user_dialog ul li:nth-child(2){width:15%;}
		#user_dialog ul li:nth-child(3){width:70%;}
		select.level{width: 262px;padding: 0 10px;
					 border: 1px solid #c5d6e0;
					 line-height: 30px;
					 height: 30px;
					 color: #666;}
		select.level::-ms-expand { display: none; }
		.ui-dialog .ui-dialog-content{margin-top:30px; padding-left:50px;}
		#detailPicId{width:80%; height:80%;}
    </style>
</head>
<body>
<div class="title"><h2>发起工作流程</h2></div>
<div class="article  matter">
    <div class="wrap-r">
        <div class="title ue-clear">
            <h2 class="title-list">
                <ul class="ue-clear">
                    <li class="current"><a href="javascript:;">固定流程</a></li>
                    <li style="width:110px;"><a href="javascript:;" style="width:108px;">自定义流程</a></li>
                </ul>
            </h2>
        </div>
        <div class="content">
            <div class="matter-content current ue-clear">
            <form id="startForm" name="startForm" method="POST">
            	<input name="processDefinitionId" id="definitionId" type="hidden"/>
            	<input name="processInstanceId" id="processInstanceId" type="hidden"/>
                <p class="long-input ue-clear">
                    <label>流程标题：</label>
                    <input type="text" id="processNameDFHC" name ="<%=ISystemConstant.PROCESS_FIX_FORM_PROPERTY %>" placeholder="发起的流程名称" />
                    <span><em style="color:red;">*</em></span>
                </p>
                <p class="long-input ue-clear">
                    <label>发起人姓名：</label>
                    <input type="text" id="startName" readonly="readonly" placeholder="" />
                </p>
                <p class="long-input ue-clear">
                    <label>重要程度：</label>
                    <select name="level" class="level">
                     
                      <option value="" selected>-- 请选择 --</option>
                      
                      <c:forEach var="level" items="${levels}">
                        
                        <option value="${level.key}">${level.value}</option>
                      
                      
                      </c:forEach>
                    
                    </select>
                </p>
                <p class="short-input ue-clear">
                <label>发起时间：</label>
                <input type="text" id="startTimeDFHC" name="<%=ISystemConstant.PROCESS_START_TIME %>" placeholder="发起时间，可以为空" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'%y-%M-%d %H:%m:%s'})" />
                </p>

                <div class="short-input select ue-clear">
                    <label>流程定义：</label>
                    <div>
                    	<span id="definitionName"></span><input type="button" onclick="javascript:checkProcess();" style="margin-left:10px;" value="选择流程" class="button"/>
                    </div>
                </div>
                <div id="startFormDate" style="display:none">
	               
				</div>
				<div id="nodeAssign" style="margin-top: 10px;margin-left: 30px;margin-right: 10px;display:none;">
					<div class="table-box">
					<table>
				    	<thead>
				        	<tr>
				                <th class="process">节点名称</th>
				                <th class="process">节点类型</th>
				                <th class="operate">人员设置</th>
				            </tr>
				        </thead>
				        <tbody id="nodeHtml">
				        	
				        </tbody>
				    </table>
					</div>
				</div>
                <div class="btn1 ue-clear">
                    <a href="javascript:;" onclick="javascript:startProcess();" id="confirm" class="confirm">提交</a>
                    <a href="javascript:;" onclick="javascript:emptyInput();" class="clear">清空内容</a>
                </div>
				</form>

                <div class="article  duty">
                    <div class="wrap-l">
                        <div class="title ue-clear">
                            <h2>预览工作流程图模板</h2>
                        </div>
                        <div class="content">
                        	<%-- 
                            <div class="today">
                                <p class="year" style="line-height: 13px;padding-left:0px;">流程列表</p>
                                <p class="date" style="padding-left:0px;">5</p>
                            </div>
                            --%>
                            <div class="table-box">
							<table>
						    	<thead>
						        	<tr>
						            	<th class="num">序号</th>
						                <th class="process">流程名称</th>
						                <th class="operate">流程图</th>
						            </tr>
						        </thead>
						        <tbody>
						        	<c:forEach items="${definitionList }" var="definitionVo" begin="0" varStatus="rowCounter" step="1">
							        	<tr>
							            	<td class="num">${rowCounter.index+1 }</td>
							                <td class="process">${definitionVo.name_ }</td>
							                <td class="node"><a href="javascript:;" onclick="javascript:lookProcessPic('${definitionVo.id_}','${definitionVo.dgrm_resource_name_ }','${definitionVo.name_ }');">查看流程图</a></td>
						            	</tr>
						            </c:forEach>
						        </tbody>
						    </table>
							</div>
							<div class="pagination ue-clear"></div>
                            <p class="short-input ue-clear newstyle">
                                <label>流程名：</label>
                                <label id="detailPicTitle" style="width: 666px;"></label>
                            </p>
                            <p class="short-input ue-clear newstyle">
                                <a href="javascript:;" class="img"><img id="detailPicId" width="100%" height="300px" src="" /></a>
                            </p>
                        </div>
                    </div>
                </div>

            </div>

             <!-- begin  自定义-->
            <div class="matter-content ue-clear" style="height: 100%;">
               
                <div style="height: 100%;">
                  <iframe src="${pageContext.request.contextPath }/pubController/demo" style="border:none;width: 100%;height: 100%; min-height:800px;"></iframe>
               
                </div>
               
            </div>
            <!-- end 自定义 -->
        </div>
    </div>
</div>

<!--流程定义展示表单 begin-->
<div id="process_model_dialog" class="zu_add_dialog" style="display:none;">
        <ul>
        	<li>选择</li>
            <li>序号</li>
            <li>流程定义名称</li>
        </ul>
        <c:forEach items="${allList }" var="definitionVo" begin="0" varStatus="rowCounter" step="1">
        <ul>	
        	<li><input type="radio" name="processId" value="${definitionVo.id_}"/></li>
            <li>${rowCounter.index+1 }</li>
            <li>${definitionVo.name_ }</li>
        </ul>
        </c:forEach>
</div>

<!--选择用户 begin-->
     <%-- <div id="user_dialog" class="zu_add_dialog" style="display:none;">
		<input id="userNodeId" type="hidden"/>
		<input id="userNodeUserId" type="hidden"/>
   <ul>
        	<li>选择</li>
            <li>序号</li>
            <li>用户名称</li>
        </ul>
        <c:forEach items="${userVos }" var="userVo" begin="0" varStatus="rowCounter" step="1"> 
		<div id="userDiv">
        <ul>	
        	<li><input type="checkbox" name="userId" value="${userVo.id}"/></li>
            <li>${rowCounter.index+1 }</li>
            <li>${userVo.name }</li>
        </ul>
        
  </c:forEach> --%>
		<div   id="user_dialog_tree">
		<input id="userNodeId" type="hidden"/>
		<input id="userNodeType" type="hidden"/>
	        <ul id="tree">
	          <li clsss="user_dialog_tree1"><input type="checkbox" onchange="doChecked(this,'all');" id="all">全部
	            <ul>
	              <c:forEach items="${addressBookGroupVos}" var="addressBookGroupVo"> 
		               <li clsss="user_dialog_tree2"><input type="checkbox" id="${addressBookGroupVo.id}" onchange="doChecked(this,'2');">${addressBookGroupVo.businessAttribute1}
		                <ul>
		                    <c:forEach items="${userVos}" var="addressBookVo"> 
		                    <c:if test="${fn:contains(addressBookVo.organizationId,addressBookGroupVo.id)}">
			                  <li clsss="user_dialog_tree3"><input type="checkbox" data-name="${addressBookVo.name}" onchange="doChecked(this,'${addressBookGroupVo.id}');"  value="${addressBookVo.id}" name="userId" class="checkPerson  ${addressBookVo.id}" >${addressBookVo.name}<c:if test="${ not empty addressBookVo.post  ||  not empty addressBookVo.originalUnitDuties  }">(</c:if><c:if test="${ not empty addressBookVo.post}">职务:<c:out value="${addressBookVo.post}"></c:out></c:if><c:if test="${ not empty addressBookVo.originalUnitDuties}">&nbsp;&nbsp;  &nbsp;原单位:<c:out value="${addressBookVo.originalUnitDuties}"></c:out></c:if><c:if test="${ not empty addressBookVo.post  ||  not empty addressBookVo.originalUnitDuties  }">)</c:if></li>
		               		</c:if>
		               		</c:forEach>
		                </ul>
		              </li> 
	              </c:forEach>
	            </ul>
	           	<ul>
	           		<li style="width: 95%;"><input type="checkbox" onchange="doChecked(this,'qt');"/>其他
	           			<ul>
	           				<c:forEach items="${userVos}" var="addressBookVo"> 
		                    <c:if test="${empty addressBookVo.organizationId}">
			                  <li style="width: 99%;"><input type="checkbox" data-name="${addressBookVo.name}" onchange="doChecked(this,'1');" name="userId"  value="${addressBookVo.id}"  class="checkPerson  ${addressBookVo.id}"  >${addressBookVo.name}<c:if test="${ not empty addressBookVo.post  ||  not empty addressBookVo.originalUnitDuties  }">(</c:if><c:if test="${ not empty addressBookVo.post}">职务:<c:out value="${addressBookVo.post}"></c:out></c:if><c:if test="${ not empty addressBookVo.originalUnitDuties}">&nbsp;&nbsp;  &nbsp;原单位:<c:out value="${addressBookVo.originalUnitDuties}"></c:out></c:if><c:if test="${ not empty addressBookVo.post  ||  not empty addressBookVo.originalUnitDuties  }">)</c:if></li> 
		               		</c:if>
		               		</c:forEach>
	           			</ul>
	           		</li>
	           	</ul>
	          </li>   
	       </ul>
	       
	       <ul id="tree1" style="display:none;">
	          <li clsss="user_dialog_tree1">全部
	            <ul>
	              <c:forEach items="${addressBookGroupVos}" var="addressBookGroupVo"> 
		               <li clsss="user_dialog_tree2">${addressBookGroupVo.businessAttribute1}
		                <ul>
		                    <c:forEach items="${userVos}" var="addressBookVo"> 
		                    <c:if test="${fn:contains(addressBookVo.organizationId,addressBookGroupVo.id)}">
			                  <li clsss="user_dialog_tree3"><input type="radio" data-name="${addressBookVo.name}" onchange="doChecked(this,'${addressBookGroupVo.id}');"  value="${addressBookVo.id}" name="userId" class="checkPerson  ${addressBookVo.id}" >${addressBookVo.name}<c:if test="${ not empty addressBookVo.post  ||  not empty addressBookVo.originalUnitDuties  }">(</c:if><c:if test="${ not empty addressBookVo.post}">职务:<c:out value="${addressBookVo.post}"></c:out></c:if><c:if test="${ not empty addressBookVo.originalUnitDuties}">&nbsp;&nbsp;  &nbsp;:<c:out value="${addressBookVo.originalUnitDuties}"></c:out></c:if><c:if test="${ not empty addressBookVo.post  ||  not empty addressBookVo.originalUnitDuties  }">)</c:if></li>
		               		</c:if>
		               		</c:forEach>
		                </ul>
		              </li> 
	              </c:forEach>
	            </ul>
	           	<ul>
	           		<li style="width: 95%;">其他
	           			<ul>
	           				<c:forEach items="${userVos}" var="addressBookVo"> 
		                    <c:if test="${empty addressBookVo.organizationId}">
			                  <li style="width: 99%;"><input type="radio" data-name="${addressBookVo.name}" onchange="doChecked(this,'1');" name="userId"  value="${addressBookVo.id}"  class="checkPerson  ${addressBookVo.id}"  >${addressBookVo.name}<c:if test="${ not empty addressBookVo.post  ||  not empty addressBookVo.originalUnitDuties  }">(</c:if><c:if test="${ not empty addressBookVo.post}">职务:<c:out value="${addressBookVo.post}"></c:out></c:if><c:if test="${ not empty addressBookVo.originalUnitDuties}">&nbsp;&nbsp;  &nbsp;原单位:<c:out value="${addressBookVo.originalUnitDuties}"></c:out></c:if><c:if test="${ not empty addressBookVo.post  ||  not empty addressBookVo.originalUnitDuties  }">)</c:if></li>
		               		</c:if>
		               		</c:forEach>
	           			</ul>
	           		</li>
	           	</ul>
	          </li>   
	       </ul>
	    </div>

</body>

<script type="text/javascript">
	var randomNum = guid();
	$(function(){
		$("#startName").val('${startName}');
		$("#tree,#tree1").treeview({
            collapsed: true,
            animated: "medium",
            control:"#sidetreecontrol",
            persist: "location"
        }); 
	});
	//通讯录组修改dialog
    $('#process_model_dialog').dialog({
        autoOpen:false,
        title:'选择流程模型',
        modal:true,
        resizable:false,
        width:450,
        height:500,
        buttons:{
            '确定':function(){
                	var definitionId = $("input[name='processId']:checked").val();
                	var definitionName = $("input[name='processId']:checked").parents('ul').find('li:last').text();
                	var key = definitionId.split(":")[0];
                	$("#definitionId").val(definitionId);
                	$("#definitionName").text(definitionName);
                	$('#process_model_dialog').dialog('close');
                	
                	$.ajax({
                	    type:'post',//可选get
                	    url:'<%=request.getContextPath()%>/workprocess/getFormData?date='+new Date(),
                	    data:{'processDefinitionId':definitionId,'taskId':'','onlyFormData':'1'},
                	    dataType:'json',
                	    async:false , //false为同步
                	    success:function(data,status){
                		  if(data.status=="0"){
                			  	zfalert("提示信息",data.message,"");
                	   	   }else{
                	   	   		//拼接开始节点自定义表单数据
								var startFormDataList = data.startFormDataList;
                	   	   		var enumTypeMap = data.enumTypeMap;
								var startFormDataHtml = operFormDateHtml(startFormDataList, enumTypeMap);
								$("#startFormDate").html(startFormDataHtml);
								$("#startFormDate").show();
								
								//if(key.indexOf('<%=ISystemConstant.PROCESS_PREFIX%>')>-1){
									//如果是自定义流程就拼接各个节点分配人员表格
									$.ajax({
				                	    type:'post',//可选get
				                	    url:'<%=request.getContextPath()%>/workprocess/getNodeData?date='+new Date(),
				                	    data:{'processDefinitionId':definitionId,'taskId':'','onlyFormData':'1'},
				                	    dataType:'json',
				                	    async:false , //false为同步
				                	    success:function(nodeData,status){
				                		  if(nodeData.status=="0"){
				                				zfalert("提示信息",nodeData.message,"");
				                	   	   }else{
												var nodeList = nodeData.nodeList;
												var nodeHtml = operNodeHtml(nodeList);
												$("#nodeHtml").html(nodeHtml);
												$('#nodeAssign').show();
				                	   	   }		
				                	   },
				                	   error:function(xhr,s1,s2){
				                	    	var message = xhr.responseText;
				                			eval("var json = "+message);
				                			if($.trim(json.error).length==0){
				                				zfalert("提示信息","数据异常,请刷新页面重试","");
				                			}else{
				                				zfalert("提示信息",json.error,"");
				                			}
				                	   }
				                	});
								//}else{
								//	$('#nodeAssign').hide();
								//}
                	   	   }		
                	   },
                	   error:function(xhr,s1,s2){
                	    	var message = xhr.responseText;
                			eval("var json = "+message);
                			if($.trim(json.error).length==0){
                				zfalert("提示信息","数据异常,请刷新页面重试","");
                			}else{
                				zfalert("提示信息",json.error,"");
                			}
                	   }
                	});
                },
            }
    });
	//选择流程模型事件
	function checkProcess(){
		$('#process_model_dialog').dialog('open');
	}
	var fileArr = [];
	//拼接流程form表单数据
	function operFormDateHtml(startFormDataList, enumTypeMap){
		var formHtml = '';
		var pix = 'zfhc_';
		var j = 0;
		for(var i=0; i<startFormDataList.length; i++){
			var startFormData = startFormDataList[i];
			formHtml += '<p class="short-input ue-clear">';
			if(startFormData.type.name=='file'){
				startFormData.id = pix+i;
				fileArr[j] = startFormData.id;
				j++;
			}
			formHtml += operHtml(startFormData, enumTypeMap);
			formHtml += '</p>';
		}
		return formHtml;
	}
	//判断数据类型,展示不同的标签
	function operHtml(formData, enumTypeMap){
		var html = '<label>'+formData.name+'：</label>';
		if(formData.type.name=='string'){//input标签
			html += '<input type="text" name="'+formData.id+'">';			
		}else if(formData.type.name=='enum'){
			html += '<select name='+formData.id+'>';
			var enumList = enumTypeMap[formData.id];
			for(var i=0; i<enumList.length; i++){
				html += '<option value="'+enumList[i].key+'">';
				html += enumList[i].value;
				html += '</option>';
			}
			html += '</select>';
		}else if(formData.type.name=='file'){
			html += '<input type="file" name="'+formData.id+'" id="'+formData.id+'"/>';
		}else if(formData.type.name=='textarea'){
			html += '<textarea name="'+formData.id+'"></textarea>';
		}
		return html;
	}
	
	//拼接任务节点html
	function operNodeHtml(nodeList){
		var html = '';
		for(var i=0; i<nodeList.length; i++){
			var nodeVo = nodeList[i];
			html += '<tr>';
			html += '<td class="process">'+nodeVo.name+'<input name="nodeId" type="hidden" value="'+nodeVo.id+'"/></td>';
			if(nodeVo.type == "sequential"){
				html += '<td class="process">串行</td>';
			}else{
				html += '<td class="process">并行</td>';
			}
			html += '<td class="node">';
			html += '<div id="peoples'+nodeVo.id+'"></div>'
			//html += '<a href="javascript:;" onclick="javascript:addPerson(\''+nodeVo.id+'\',\''+nodeVo.groups+'\');">添加人员</a>';
			html += '<a href="javascript:;" style="margin-left: 15px;" onclick="javascript:updatePerson(\''+nodeVo.id+'\',\''+nodeVo.groups+'\',\''+nodeVo.type+'\');">添加人员</a>';
			html += '</td>';
			html += '</tr>';
		}
		return html;
	}
	
	//预览工作流程图模板分页
	$('.pagination').pagination(${pageTotal},{
		callback: function(page){
			window.location.href='<%=request.getContextPath()%>/workprocess/workstart?currentPage='+(page+1);
		},
		display_msg: true,
		setPageNo: true,
		items_per_page:5,
		current_page:${currentPage-1}
	});
	
	//查看流程图点击事件
	function lookProcessPic(pdid, resourceName, name){
		$("#detailPicTitle").text(name);
		//http://localhost:8080/miit/model/read-resource?pdid=process:1:32546&resourceName=1234562.process.png
		var srcurl = "<%=request.getContextPath()%>/model/read-resource?pdid="+pdid+"&resourceName="+resourceName;
		$("#detailPicId").attr("src",srcurl);
	}
	
	var isRun = 0;
	//提交启动流程事件
	function startProcess(){
		if(isStrEmpty($('#processNameDFHC').val())){
			zfalert("提示信息","请输入流程标题!","");
			return false;
		}
		if(isStrEmpty($('#definitionName').html())){
			zfalert("提示信息","请选择流程!","");
			return false;
		}		
		
		var level=$("select[name='level'] option:selected").val();
		if(typeof level=='undefined' || $.trim(level).length==0){
			zfalert("提示信息","请选择任务级别","");
			return false;
		}
		if(isRun == 1){
			zfalert("提示信息","请勿重复提交","");
			return;
		}
		isRun = 1;
		
		
		var dateStr=formatDate(new Date().getTime(),'yyyy-MM-dd HH:mm:ss');
		$("#startTimeDFHC").val(dateStr);
		$('#processInstanceId').val(randomNum);
		var params = jQuery("#startForm").serialize(); // http request parameters. 
		params = decodeURIComponent(params,true);
		
		var url = "<%=request.getContextPath()%>/workprocess/start";
		successToUrls ="<%=request.getContextPath()%>/workprocess/workShow.action?titleType=myWork";
		params = decodeURIComponent(params,true);
		params = encodeURI(encodeURI(params));
		
	<%-- 	ajaxFileUploadLiu("<%=request.getContextPath()%>/workprocess/start",fileArr,params,"<%=request.getContextPath()%>/workprocess/workShow.action?titleType=myWork");
	 --%>	
		 $.ajaxFileUpload({  
		        url:url+"?"+params,
		        type:'POST',
		        secureuri:false,                           //是否启用安全提交,默认为false   
		        fileElementId:fileArr,                  //文件选择框的id属性  
		        dataType:'json',                           //服务器返回的格式,可以是json或xml等  
		        success:function(data,status){
					  if(data.status=="0"){
						  	zfalert("提示信息",data.message,"");
				   	   }else{
				   		   zfalert("提示信息",data.message,aa);
				   	   }	
						isRun = 0;
				},
				error:function(xhr,s1,s2){
				    	var message = xhr.responseText;
						eval("var json = "+message);
						if($.trim(json.error).length==0){
							zfalert("警告","数据异常,请刷新页面重试!","");
						}else{
							zfalert("提示信息",json.error,"");
						}
						isRun = 0;
				   }
				});
	
	}
	
	//根据毫秒数格式化时间
var formatDate = function(time, format){
    var t = new Date(time);
    var tf = function(i){return (i < 10 ? '0' : '') + i};
    return format.replace(/yyyy|MM|dd|HH|mm|ss/g, function(a){
        switch(a){
            case 'yyyy':
                return tf(t.getFullYear());
                break;
            case 'MM':
                return tf(t.getMonth() + 1);
                break;
            case 'mm':
                return tf(t.getMinutes());
                break;
            case 'dd':
                return tf(t.getDate());
                break;
            case 'HH':
                return tf(t.getHours());
                break;
            case 'ss':
                return tf(t.getSeconds());
                break;
        }
    })
}

	//清空内容点击事件
	function emptyInput(){
		$("#startTimeDFHC").val('');
		$("#processNameDFHC").val('');
	}
	
	//选择人员dialog
    $('#user_dialog_tree').dialog({
        autoOpen:false,
        title:'选择人员',
        modal:true,
        resizable:false,
        width:450,
        height:500,
        buttons:{
            '确定':function(){
	            	var ckvId ='';//选中的用户ID
	            	var ckvName = '';//选中用户名称
	        		$('#user_dialog_tree').find('input[name="userId"]:checked').each(function(){ 
	        			if(ckvId==''){
	        				ckvId = $(this).val();
	        			}else{
    	            		if(ckvId.indexOf($(this).val()) == -1){

	        					ckvId += ','+$(this).val();
    	            		}
	        			}
	        			if(ckvName==''){
	        				ckvName = $(this).data("name");
	        			}else{

	        				ckvName += ','+$(this).data("name");
	        			}
	        		});
	        		if(ckvName != '' && ckvName.length >12){//用户名称组长度大于12时，截断
	        			ckvName = ckvName.substr(0,12)+"...";
	        		}
	        		var nodeId = $('#userNodeId').val();
	        		var nodeType = $('#userNodeType').val();//节点类型，是否串行
	        		var html = "";
	        		if(nodeType == "sequential"){//串行加一行
		        		if(ckvId == ''){
		        			$('#user_dialog_tree').dialog('close');
		        			return;
		        		}
	        			html += '<ul id="ul'+ckvId+'"><li style="float:left;width:40%">人员名称：'+ckvName+'<input type="hidden"  placeholder ="结束时间，可以为空！" name = "userId'+nodeId+'"  class="user'+nodeId+'" value="'+ckvId+'"/></li>';
		        		html += '<li style="float:left;width:40%"><input placeholder ="结束时间，可以为空！" name="endTime'+ckvId+'" onfocus="WdatePicker({dateFmt:&quot;yyyy-MM-dd HH:mm:ss&quot;,minDate:&quot;%y-%M-%d %H:%m:%s&quot;})"/></li>';
		        		html += '<li style="float:left;width:20%"><a href="javascript:void(0);" onclick="$(\'#ul'+ckvId+'\').remove()"class="del">删除</a></li></ul>'
			        	
	        		}else{//并行直接覆盖
	        			if(ckvId == ''){
	        				$("#ul"+nodeId).remove();//不选中用户移除之前选中的数据
		        			$('#user_dialog_tree').dialog('close');
		        			return;
		        		}
	        			$("#peoples"+nodeId).html("");
	        			html = '<ul id="ul'+nodeId+'"><li style="float:left;width:40%">人员名称：'+ckvName+'<input type="hidden" name = "userId'+nodeId+'"class="user'+nodeId+'" value="'+ckvId+'"/></li>';
	        			html += '<li style="float:left;width:40%"><input placeholder ="结束时间，可以为空！"  name="endTime'+nodeId+'" onfocus="WdatePicker({dateFmt:&quot;yyyy-MM-dd HH:mm:ss&quot;,minDate:&quot;%y-%M-%d %H:%m:%s&quot;})"/></li>';
	        			html += '<li style="float:left;width:20%"><a href="javascript:void(0);" onclick="$(\'#ul'+nodeId+'\').remove()"class="del">删除</a></li></ul>'
	        		}
	        		$("#peoples"+nodeId).append(html);
	        		$('#user_dialog_tree').dialog('close');
	        		<%-- var nodeId = $('#userNodeId').val();
	        		var definitionId = $("#definitionId").val();
	        		var id = $('#userNodeUserId').val();
	        		var endTime = $("#endTime").val();
	        		$('#user_dialog_tree').find("input[name='userId']").removeAttr("checked","checked");
	        		$.ajax({
                	    type:'post',//可选get
                	    url:'<%=request.getContextPath()%>/generalbusinessprocess/insertProcPerson?date='+new Date(),
                	    data:{'processDefinitionId':definitionId,'nodeId':nodeId,'procIntId':randomNum,'usersId':ckvId,'id':id,'endTime':endTime},
                	    dataType:'json',
                	    async:false , //false为同步
                	    success:function(nodeData,status){
                		  if(nodeData.status=="0"){
                			  	zfalert("提示信息",nodeData.message,"");
                	   	   }else{
                	   			zfalert("提示信息","操作成功!","");
								$('#userNodeUserId_'+nodeId).val(nodeData.bean.id);
								$('#user_dialog_tree').dialog('close');
                	   	   }		
                	   },
                	   error:function(xhr,s1,s2){
                	    	var message = xhr.responseText;
                			eval("var json = "+message);
                			if($.trim(json.error).length==0){
                				zfalert("提示信息","数据异常,请刷新页面重试","");
                			}else{
                				zfalert("提示信息",json.error,"");
                			}
                	   }
                	});    --%>            	
                },
            }
    });
	//选择人员分配
	/*function addPerson(nodeId, roleIds){
		//如果是自定义流程就拼接各个节点分配人员表格
		$.ajax({
    	    type:'post',//可选get
    	    url:'<%=request.getContextPath()%>/workprocess/getUserByRoleId?date='+new Date(),
    	    data:{'roleIds':roleIds},
    	    dataType:'json',
    	    async:false , //false为同步
    	    success:function(data,status){
    		  if(data.status=="0"){
    			  zfalert("提示信息",data.message,"");
    	   	   }else{
					//alert(data.userVos);
					var userHtml = operUserHtml(data.userVos);
					$('#userDiv').html(userHtml);
					$("#userNodeId").val(nodeId);
					$('#user_dialog_tree').dialog('open');
    	   	   }		
    	   },
    	   error:function(xhr,s1,s2){
    	    	var message = xhr.responseText;
    			eval("var json = "+message);
    			if($.trim(json.error).length==0){
    				zfalert("提示信息","数据异常,请刷新页面重试","");
    			}else{
    				zfalert("提示信息",json.error,"");
    			}
    	   }
    	});
	}*/
	
	//拼接任务节点选择的分配人员列表
	/*function operUserHtml(userVos){
		var html = '';
		for(var i=0; i<userVos.length; i++){
			var user = userVos[i];
			html += '<ul>';
			html += '<li><input type="checkbox" name="userId" value="'+user.userid+'"/></li>';
			html += '<li>'+(i+1)+'</li>';
			html += '<li>'+user.username+'</li>';
			html += '</ul>';
		}
		return html;
	}*/
	
	//修改人员分配
	function updatePerson(nodeId, roleIds,type){
		//addPerson(nodeId, roleIds);
		//$('#user_dialog').dialog('close');
		$("#userNodeId").val(nodeId);
		$("#userNodeType").val(type);
		//var definitionId = $("#definitionId").val();
		var userIds = ",";
		$(".user"+nodeId).each(function(){//判断同一用户是否多次选中
			if(userIds.indexOf(','+$(this).val()+',')==-1){
				userIds += $(this).val() + ",";
			}
		});
		if(userIds != "" &&  userIds.length > 1){
			userIds = userIds.substr(1,userIds.length-1);
		}
		$('#user_dialog_tree').find(":checkbox,:radio").removeAttr("checked","checked");//全部取消选中
		$('#user_dialog_tree').find(":checkbox").attr("disabled", false);//取消禁止选中
	   	if(type == "sequential"){//串行每次只能选一个用户
	   		if(userIds != ""){
				$('#user_dialog_tree').find('input[name="userId"]').each(function(){ 
					if(userIds.indexOf($(this).val())>-1){
						$(this).attr("disabled", true);//禁止选中
					}
	    		});
		   	}
	   		$("#tree").hide();
	   		$("#tree1").show();
	   	}else{
	   		/* if(userIds != ""){
				$('#user_dialog_tree').find('input[name="userId"]').each(function(){ 
					if(userIds.indexOf($(this).val())>-1){
						$(this).prop("checked",true);//勾选 
					}
	    		});
		   	} */
	   		$("#tree1").hide();
	   		$("#tree").show();
	   	}
		   	
		$('#user_dialog_tree').dialog('open');
		<%-- $.ajax({
    	    type:'post',//可选get
    	    url:'<%=request.getContextPath()%>/generalbusinessprocess/getProcPerson?date='+new Date(),
    	    data:{'processDefinitionId':definitionId,'nodeId':nodeId,'procIntId':randomNum},
    	    dataType:'json',
    	    async:false , //false为同步
    	    success:function(data,status){
    		  if(data.status=="0"){
    			  zfalert("提示信息",data.message,"");
    	   	   }else{
    	   		    var personId = data.personId;
    	   		    $('#userNodeUserId').val(personId);
    	   		  	$('#userNodeUserId_'+nodeId).val(personId);
    	   		   	var userIds = data.userIds;
    	   		   	$('#user_dialog_tree').find("input[name='userId']").removeAttr("checked","checked");
    	   		   	if(userIds != ""){
						$('#user_dialog_tree').find('input[name="userId"]').each(function(){ 
							if(userIds.indexOf($(this).val())>-1){
								$(this).prop("checked",true);//勾选 
							}
		        		});
    	   		   	}
					$('#user_dialog_tree').dialog('open');
    	   	   }		
    	   },
    	   error:function(xhr,s1,s2){
    	    	var message = xhr.responseText;
    			eval("var json = "+message);
    			if($.trim(json.error).length==0){
    				zfalert("提示信息","数据异常,请刷新页面重试","");
    			}else{
    				zfalert("提示信息",json.error,"");
    			}
    	   }
    	});   --%>
	}
	
	function  doChecked(obj,objId){
    	var isCheck=$(obj).is(':checked');
    	if(isCheck){
    		//子input默认选择
    		$(obj).parent("li").find("input").prop("checked","checked");
    	}else{
    		if(objId !='all'){
    			$("#all").removeAttr("checked");
    			$("#"+objId).removeAttr("checked");
    		}
    		//移除子input
    		$(obj).parent("li").find("input").removeAttr("checked");
    	}
    }
	
	function fileUpload(fileNameId,hideIdName){
		var rootPath = '<%=ISystemConstant.PREDEFINED_TEMP_PATH%>/'+randomNum;
		var file = $('#'+fileNameId).val();
		var fileName = file.replace(/^.+?\\([^\\]+?)(\.[^\.\\]*?)?$/gi,"$1");
		var fileExt=file.replace(/.+\./,"");
		fileName += "."+fileExt;
		rootPath = rootPath+'/'+fileName;
		$("#"+hideIdName).val(rootPath);
	}
	
	
    $(".title-list ul").on("click","li",function(){
        var aIndex = $(this).index();
        $(this).addClass("current").siblings().removeClass("current");
        $(".matter-content").removeClass("current").eq(aIndex).addClass("current");
    });

    $(".duty").find("tbody").find("tr:even").css("backgroundColor","#eff6fa");

    $(".select-title").on("click",function(){
        $(".select-list").toggle();
        return false;
    });
    $(".select-list").on("click","li",function(){
        var txt = $(this).text();
        $(".select-title").find("span").text(txt);
    });

    showRemind('input[type=text], textarea','placeholder');
</script>
</html>